René's URL Explorer Experiment


Title: Performance improvement of IfcParse tokenizer by stgatilov · Pull Request #82 · IfcOpenShell/IfcOpenShell · GitHub

Open Graph Title: Performance improvement of IfcParse tokenizer by stgatilov · Pull Request #82 · IfcOpenShell/IfcOpenShell

X Title: Performance improvement of IfcParse tokenizer by stgatilov · Pull Request #82 · IfcOpenShell/IfcOpenShell

Description: In my opinion, most of the performance issues in IfcParse are due to too many dynamic memory allocations. This PR is dedicated to removing memory allocations in tokenization process, at least for numbers and operators. As a result, opening a 47Mb file in our IfcParse-based project now takes 9.5 seconds instead of 12.5 seconds. According to MSVC profiler, samples count of IfcParse.dll has reduced from 3600 to 2600. Built with MSVC2013 x64 with additional optimizations enabled. In the new tokenization system, most of the information for each token is determined at the moment it is created, and it is saved within the Token struct itself. In particular: startPos - index of first char in token (was saved before). endPos - index of the after-the-last char of token (I thought it would be useful, but it is not actually used). type - operator/keyword/integer/bool/whatever. value - only for some types of tokens, stored in union. For simple tokens, their values are determined on creation without any memory allocations. This allows to avoid costly creation of std::string-s in IfcSpfLexer::TokenString function. There are several points I would like to discuss about these changes: (1) According to STEP specification, EOL chars may appear in any tokens. So breaking a real number into two lines is considered a correct STEP. This is rather unpleasant for tokenization, because it is not possible to parse numbers with standard libraries "in-place" (unless all EOLs are removed even before tokenization). In order to support such weird tokens, I copy each token into a 64-byte buffer on stack, removing all EOL in process (see function RemoveTokenSeparators). This allows to avoid dynamic allocation, but limits length of any integer or real number to 63 characters. I wonder if it is really a problem and if anyone knows a way to fix it (without dynamic allocation). For example, the following valid numbers would screw tokenization process in the PR: integer: 00000...[repeat 70 times]...0000078 real: 14.1039...[write 70 digits]...23569 (2) IfcParse library lacks an assert macro. Throwing exception is the right thing to do on ill-formatted inputs. But sometimes it is desirable to check for conditions which must be true by construction, in order to simplify debugging process. And throwing exception in a small getter function is a waste of program time and space. See functions asInt, asFloat and other for example.

Open Graph Description: In my opinion, most of the performance issues in IfcParse are due to too many dynamic memory allocations. This PR is dedicated to removing memory allocations in tokenization process, at least for n...

X Description: In my opinion, most of the performance issues in IfcParse are due to too many dynamic memory allocations. This PR is dedicated to removing memory allocations in tokenization process, at least for n...

Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/pull/82

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:83cc1989-fd86-ddd9-3d72-421819279df1
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB7EE:EE4AB:A89732:E56D4E:6B048380
html-safe-nonceff8ed200d0e23b4a934d8727411d855312fde9ed02d90c9af99b1a8100708de9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCN0VFOkVFNEFCOkE4OTczMjpFNTZENEU6NkIwNDgzODAiLCJ2aXNpdG9yX2lkIjoiNzM0MTYwOTU4MDkxNzIzNjQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac6598ecb7c97dfa7aa5ee3781e6a14c5567fb9db5431dac7d4203fc6c58fdbf4d
hovercard-subject-tagpull_request:72310139
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
twitter:imagehttps://avatars.githubusercontent.com/u/13484213?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/13484213?s=400&v=4
og:image:altIn my opinion, most of the performance issues in IfcParse are due to too many dynamic memory allocations. This PR is dedicated to removing memory allocations in tokenization process, at least for n...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None1d5c152376e38b7d2e37f3d5179be29a73bee93b85110da28a4eebe1159cdc70
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git
octolytics-dimension-user_id13692563
octolytics-dimension-user_loginIfcOpenShell
octolytics-dimension-repository_id40473201
octolytics-dimension-repository_nwoIfcOpenShell/IfcOpenShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id40473201
octolytics-dimension-repository_network_root_nwoIfcOpenShell/IfcOpenShell
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef5017e8ff4ea25a8011fcf0f2a0e430c60dc86c8
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/IfcOpenShell/IfcOpenShell/pull/82/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fpull%2F82%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fpull%2F82%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=IfcOpenShell%2FIfcOpenShell
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
IfcOpenShellhttps://github.com/IfcOpenShell
IfcOpenShellhttps://github.com/IfcOpenShell/IfcOpenShell
Codehttps://github.com/IfcOpenShell/IfcOpenShell
Issues1.2k (1.2k)https://github.com/IfcOpenShell/IfcOpenShell/issues
Pull requests937 (937)https://github.com/IfcOpenShell/IfcOpenShell/pulls
Discussionshttps://github.com/IfcOpenShell/IfcOpenShell/discussions
Actionshttps://github.com/IfcOpenShell/IfcOpenShell/actions
Projectshttps://github.com/IfcOpenShell/IfcOpenShell/projects
Wikihttps://github.com/IfcOpenShell/IfcOpenShell/wiki
Security and qualityhttps://github.com/IfcOpenShell/IfcOpenShell/security
Insightshttps://github.com/IfcOpenShell/IfcOpenShell/insights
Sign up for GitHub https://github.com/signup?return_to=%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2Fnew%2Fchoose
aothmshttps://github.com/aothms
IfcOpenShell:masterhttps://github.com/IfcOpenShell/IfcOpenShell/tree/master
stgatilov:masterhttps://github.com/stgatilov/IfcOpenShell/tree/master
Conversation 11 https://github.com/IfcOpenShell/IfcOpenShell/pull/82
Commits 15 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits
Checks 0 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/checks
Files changed https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
Please reload this pagehttps://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
Performance improvement of IfcParse tokenizer https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files#top
Show all changes 15 commits https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
2b4d804 Applied MSVC tabify to IfcParse.cpp/h. stgatilov Jun 1, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/2b4d804251847d7b67f8bd84a2812a7565b01a63
6dd0c48 Now Argument base class has throwing implementation for each conversi… stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/6dd0c48acd90f8c19796c99ca981cc9ea6c9c704
c438273 Added NullArgument class for the case when null arguments appear afte… stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/c438273501ddcc6f199cbe55d4066252a5341f56
dc688bd Now operator tokens are handled just like any other token. stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/dc688bdf57dd93e7b885a4dafe052cf59aa7dd3b
42e6eb3 Refactoring: Token is now a struct with good fields, not a nameless p… stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/42e6eb3e7050423a0201a00a0ea71eff0a9383f1
6760beb Now end position of token is set at its construction. stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/6760beb5665988af2000b343a418dc6887adcb1c
b44547c Now type of token is determined on construction, as* function simply … stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/b44547c93c93a9aede2ed6dd41541dfeeb927ae8
a5671f7 Now int-s, float-s and some etc are parsed when token is created. stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/a5671f761c4787f695b7d8bfaa90b73bddb2ef40
d14ab10 Implemented simple way to remove spaces in parsing. stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/d14ab10401a42bfa78b5aa64e29ba7602433796e
a1a5fd7 Tokens are now created without allocations. stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/a1a5fd7ddd982e5e51a40c90bf78f147ac60b6e2
9b9e253 Call RemoveTokenSeparators once for every token. stgatilov May 25, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/9b9e25341320874102f7ddf1cc4fefd3b8f06bb2
9e5e95a Added temporary std::string object in lexer (for optimization purposes). Jun 2, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/9e5e95adcfd52f54b942e89dd3586d7dbfbd79fc
1787167 Reimplemented asString without allocations. Jun 2, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/17871674a269f07c384106aaeb2c1be5a741c653
b128b2e Parsing keywords without allocations. Jun 2, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/b128b2e96b2c698026d03d3fba9ad048aa6f1808
35123f3 Added checks for type to tokenFunc::as*** functions. Jun 9, 2016 https://github.com/IfcOpenShell/IfcOpenShell/pull/82/commits/35123f3c35acf271ef745dab347d511bddba4466
Clear filters https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
Please reload this pagehttps://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
Please reload this pagehttps://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
IfcParse.cpp https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files#diff-b040b6c3201487d58cce8bdf084d9299d961719c7f722ca4802855a2f3daa818
IfcParse.h https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files#diff-8aedc8b128e54e9f738b0aecf19efe0ebd9d298c0e6e4668ca315933804d9f43
IfcUtil.cpp https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files#diff-890c1db77394a9381d772387e20ec4777aade93a49607db72856ac72649baa23
IfcUtil.h https://github.com/IfcOpenShell/IfcOpenShell/pull/82/files#diff-bd4e08a8c64c62fed0ccb47016e53a0526a296a6f004e3939875dd026cafd3f9
Please reload this pagehttps://github.com/IfcOpenShell/IfcOpenShell/pull/82/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.