René's URL Explorer Experiment


Title: Low decompression speed in multithreading · Issue #269 · python-lz4/python-lz4 · GitHub

Open Graph Title: Low decompression speed in multithreading · Issue #269 · python-lz4/python-lz4

X Title: Low decompression speed in multithreading · Issue #269 · python-lz4/python-lz4

Description: As far as i understand, the GIL should be dropped when calling the underlying LZ4 C library during compression and decompression, see lz4.block.decompress I only see a minor speedup when using multiple threads for decompression using pyt...

Open Graph Description: As far as i understand, the GIL should be dropped when calling the underlying LZ4 C library during compression and decompression, see lz4.block.decompress I only see a minor speedup when using mult...

X Description: As far as i understand, the GIL should be dropped when calling the underlying LZ4 C library during compression and decompression, see lz4.block.decompress I only see a minor speedup when using mult...

Opengraph URL: https://github.com/python-lz4/python-lz4/issues/269

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Low decompression speed in multithreading","articleBody":"As far as i understand, the GIL should be dropped when calling the underlying LZ4 C library during compression and decompression, see [lz4.block.decompress](https://github.com/python-lz4/python-lz4/blob/58df0834b57d485f2483bf5ccf1007c313b25557/lz4/block/_block.c#L355-L361)\r\n\r\nI only see a minor speedup when using multiple threads for decompression using python-lz4 4.3.2 on a 6 core Intel i5-8400 on Debian 11 and also not on a Amd Ryzen 5900X on Windows 10, neither with Python 3.11.1 nor 3.8.10.\r\n\r\nCompression speed seems to increase almost linearly with the number of threads.\r\n\r\nThe following code gives me about 4500MB/s decompression speed (slight underestimation due to some overhead from starting the threads) when using 6 threads and ~4300MB/s when using 1 thread on an AMD Ryzen 5900X on Windows 10.  Using lz4.frame yields similar results. Using py-lz4framed instead gives me about 13000MB/s using 6 threads and ~8300MB/s on 1 thread (not sure the compression settings are the same, but at the very least there is some speedup for multithreading).\r\n\r\n\r\n```python\r\nimport os\r\nimport threading\r\nimport time\r\nimport lz4.block\r\n\r\nsize_mb = 2000\r\nn_threads = 6\r\n\r\ninput_data = size_mb * 1024 * os.urandom(1024)\r\ncompressed = lz4.block.compress(input_data)\r\ninput_data = None\r\n\r\n\r\ndef decompress(data):\r\n    start_time = time.perf_counter()\r\n    thread_start_time = time.thread_time()\r\n    lz4.block.decompress(data)\r\n    stop_time = time.perf_counter()\r\n    thread_stop_time = time.thread_time()\r\n    print(f\"{threading.current_thread()} Decompression took {(stop_time-start_time)*1000:.3f}ms \"\r\n          f\"(Thread time: {(thread_stop_time-thread_start_time)*1000:.3f}ms)\\n\")\r\n\r\n\r\nthreads = [threading.Thread(name=str(i), target=decompress, args=(compressed,)) for i in range(n_threads)]\r\n\r\nstart_thread_time = time.perf_counter()\r\n[t.start() for t in threads]\r\n[t.join() for t in threads]\r\ndone_thread_time = time.perf_counter()\r\nduration = done_thread_time - start_thread_time\r\nMBs = n_threads*size_mb/duration\r\nprint(f\"Total time: {duration}s : {MBs}MB/s\")\r\n```\r\n","author":{"url":"https://github.com/Dalbasar","@type":"Person","name":"Dalbasar"},"datePublished":"2023-01-02T21:26:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/269/python-lz4/issues/269"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d7364fd6-0e0c-c81b-8b5b-3da5a0e4036c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9412:46893:1F1258C:2B93AD7:698233FE
html-safe-nonce81bb54878c7966d40281656edfa159c50a3ff99685cb46fc8fd9e71f58fe0d33
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDEyOjQ2ODkzOjFGMTI1OEM6MkI5M0FENzo2OTgyMzNGRSIsInZpc2l0b3JfaWQiOiI1ODkzNDQ2NzE2Nzk5MjAyMzAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacd18f20a4c41552d793ae040a7aaaea2a8f5ce39672d7c7af524832b7e6270544
hovercard-subject-tagissue:1516731443
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-lz4/python-lz4/269/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f607bb51b47c7de323d60f6066acb63d649c751e2202889479349b9d14760b71/python-lz4/python-lz4/issues/269
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f607bb51b47c7de323d60f6066acb63d649c751e2202889479349b9d14760b71/python-lz4/python-lz4/issues/269
og:image:altAs far as i understand, the GIL should be dropped when calling the underlying LZ4 C library during compression and decompression, see lz4.block.decompress I only see a minor speedup when using mult...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameDalbasar
hostnamegithub.com
expected-hostnamegithub.com
None9135c12c87e8ba63197821abe054b7c0a2842a97636ee220df564bb0788e556d
turbo-cache-controlno-preview
go-importgithub.com/python-lz4/python-lz4 git https://github.com/python-lz4/python-lz4.git
octolytics-dimension-user_id18689658
octolytics-dimension-user_loginpython-lz4
octolytics-dimension-repository_id57201963
octolytics-dimension-repository_nwopython-lz4/python-lz4
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id57201963
octolytics-dimension-repository_network_root_nwopython-lz4/python-lz4
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release6b281db2f76bdbf4b45c30b597223c551b06e6e0
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/python-lz4/python-lz4/issues/269#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-lz4%2Fpython-lz4%2Fissues%2F269
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-lz4%2Fpython-lz4%2Fissues%2F269
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-lz4%2Fpython-lz4
Reloadhttps://patch-diff.githubusercontent.com/python-lz4/python-lz4/issues/269
Reloadhttps://patch-diff.githubusercontent.com/python-lz4/python-lz4/issues/269
Reloadhttps://patch-diff.githubusercontent.com/python-lz4/python-lz4/issues/269
python-lz4 https://patch-diff.githubusercontent.com/python-lz4
python-lz4https://patch-diff.githubusercontent.com/python-lz4/python-lz4
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-lz4%2Fpython-lz4
Fork 81 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-lz4%2Fpython-lz4
Star 297 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-lz4%2Fpython-lz4
Code https://patch-diff.githubusercontent.com/python-lz4/python-lz4
Issues 19 https://patch-diff.githubusercontent.com/python-lz4/python-lz4/issues
Pull requests 9 https://patch-diff.githubusercontent.com/python-lz4/python-lz4/pulls
Actions https://patch-diff.githubusercontent.com/python-lz4/python-lz4/actions
Projects 0 https://patch-diff.githubusercontent.com/python-lz4/python-lz4/projects
Security 0 https://patch-diff.githubusercontent.com/python-lz4/python-lz4/security
Insights https://patch-diff.githubusercontent.com/python-lz4/python-lz4/pulse
Code https://patch-diff.githubusercontent.com/python-lz4/python-lz4
Issues https://patch-diff.githubusercontent.com/python-lz4/python-lz4/issues
Pull requests https://patch-diff.githubusercontent.com/python-lz4/python-lz4/pulls
Actions https://patch-diff.githubusercontent.com/python-lz4/python-lz4/actions
Projects https://patch-diff.githubusercontent.com/python-lz4/python-lz4/projects
Security https://patch-diff.githubusercontent.com/python-lz4/python-lz4/security
Insights https://patch-diff.githubusercontent.com/python-lz4/python-lz4/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/python-lz4/python-lz4/issues/269
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/python-lz4/python-lz4/issues/269
Low decompression speed in multithreadinghttps://patch-diff.githubusercontent.com/python-lz4/python-lz4/issues/269#top
https://github.com/Dalbasar
https://github.com/Dalbasar
Dalbasarhttps://github.com/Dalbasar
on Jan 2, 2023https://github.com/python-lz4/python-lz4/issues/269#issue-1516731443
lz4.block.decompresshttps://github.com/python-lz4/python-lz4/blob/58df0834b57d485f2483bf5ccf1007c313b25557/lz4/block/_block.c#L355-L361
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

Viewport: width=device-width


URLs of crawlers that visited me.