-
Notifications
You must be signed in to change notification settings - Fork 22
Multi-threading support for the tracer #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
673a638
add threading trace_callback
KRRT7 6a23204
Create testbench.py
KRRT7 85b6c73
db cleanup
KRRT7 94ae5bc
Merge branch 'main' into tracer_tracker
misrasaurabh1 53406de
remove spaghetti code
KRRT7 e9539c1
ruff format
KRRT7 7f2167a
integrate testbench as E2E replay test
KRRT7 a2d4c4b
consolidate logic around tracer
KRRT7 122f920
workload expects 4, not 5 funcs
KRRT7 b383d09
single tracer test
KRRT7 b95822a
cleanup
KRRT7 ab5409f
adjust traced expectations
KRRT7 e93bd84
Update tracer.py
KRRT7 c12071e
adjust coverage expectations
KRRT7 2f4bdd9
Merge branch 'main' into tracer_tracker
KRRT7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
.github/workflows/end-to-end-test-tracer-replay_testbench.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: end-to-end-test | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| tracer-replay-testbench: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| CODEFLASH_AIS_SERVER: prod | ||
| POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} | ||
| CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }} | ||
| COLUMNS: 110 | ||
| MAX_RETRIES: 3 | ||
| RETRY_DELAY: 5 | ||
| EXPECTED_IMPROVEMENT_PCT: 10 | ||
| CODEFLASH_END_TO_END: 1 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Set up Python 3.11 for CLI | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| python-version: 3.11.6 | ||
|
|
||
| - name: Install dependencies (CLI) | ||
| run: | | ||
| uv tool install poetry | ||
| uv venv | ||
| source .venv/bin/activate | ||
| poetry install --with dev | ||
|
|
||
| - name: Run Codeflash to optimize code | ||
| id: optimize_code | ||
| run: | | ||
| source .venv/bin/activate | ||
| poetry run python tests/scripts/end_to_end_test_tracer_replay_testbench.py | ||
24 changes: 24 additions & 0 deletions
24
code_to_optimize/code_directories/simple_tracer_e2e/testbench.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from concurrent.futures import ThreadPoolExecutor | ||
|
|
||
| def funcA(number): | ||
| k = 0 | ||
| for i in range(number * 100): | ||
| k += i | ||
| # Simplify the for loop by using sum with a range object | ||
| j = sum(range(number)) | ||
|
|
||
| # Use a generator expression directly in join for more efficiency | ||
| return " ".join(str(i) for i in range(number)) | ||
|
|
||
|
|
||
| def test_threadpool() -> None: | ||
| pool = ThreadPoolExecutor(max_workers=3) | ||
| args = list(range(10, 31, 10)) | ||
| result = pool.map(funcA, args) | ||
|
|
||
| for r in result: | ||
| print(r) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_threadpool() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.